import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/order/order_goods_item.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_core/src/get_main.dart';

import '../../routes/routes.dart';

class CommentOrderItem extends StatelessWidget {
  ///订单ID
  final String? id;

  ///订单号
  final String? orderSn;

  ///订单时间
  final String? orderTime;

  ///订单金额
  final double? totalAmount;

  ///评价内容
  final String? comment;

  ///订单商品列表
  final List goodsList;

  final bool isShowPingJia;

  CommentOrderItem({
    super.key,
    required this.orderSn,
    required this.orderTime,
    required this.totalAmount,
    required this.goodsList,
    required this.id,
    this.comment = '',
    required this.isShowPingJia,
  });

  late Widget actionButtons; //操作按钮组
  late Widget statusWidget; //右上角的状态

  @override
  Widget build(BuildContext context) {
    return BaseInteractive(
      onClick: () => {},
      childWidget: Container(
        margin: EdgeInsets.only(bottom: 10.w),
        decoration: border_radis(Colors.white),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            //标题栏
            Container(
              padding: EdgeInsets.all(10.w),
              // height: 28,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    "订单编号：$orderSn",
                    style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w300),
                  ),
                ],
              ),
            ),
            //订单的商品列表
            Container(
                padding: EdgeInsets.only(left: 10.w, right: 10.w),
                child: Column(
                  children: [
                    for (var goodsItem in goodsList) ...[
                      // 创建 OrderGoodsItem 小部件
                      OrderGoodsItem(
                        goodsImg: goodsItem['img'],
                        title: goodsItem['goodsName'],
                        tags: goodsItem['tags'] ?? [],
                        price: goodsItem['price'],
                        num: goodsItem['buyNum'],
                        totalAmount: 0,
                        status: goodsItem['status'],
                        isComment: goodsItem['isComment'],
                        channelID: goodsItem['goodsId'],
                        orderID: id,
                        paySn: '',
                        sn: '',
                        star: goodsItem['channelStars'],
                        comment: goodsItem['commentText'],
                        unit: goodsItem['unit'],
                        isShowSpec: true,
                        spuSpecBody: goodsItem['spuSpecBody'] ?? '',
                        isShowPingJia: isShowPingJia,
                        isShowPingJiaKuang: true,
                      ),
                    ],
                  ],
                )),

            Container(
              padding: EdgeInsets.all(10.w),
              alignment: Alignment.centerRight,
              child: Text(
                "感谢您的用心评价",
                style: setTextStyle(
                  10,
                  FontWeight.w300,
                  Tools.fromHex("#999999"),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
